home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import warnings
- warnings.filterwarnings('ignore', 'apt API not stable yet', FutureWarning)
- import apt
- import os
-
- class MyCache(apt.Cache):
-
- def __init__(self, progress = None):
- apt.Cache.__init__(self, progress)
- pipe = os.popen('dpkg --print-architecture')
- self._arch = pipe.read().strip()
- del pipe
- if not self._depcache.BrokenCount == 0:
- raise AssertionError
-
-
- def pkgDependsOn(self, pkgname, depends_name):
- ''' check if a given pkg depends on a given dependencie '''
- if not self.has_key(pkgname):
- return False
- pkg = self[pkgname]
- candver = self._depcache.GetCandidateVer(pkg._pkg)
- if candver == None:
- return False
- dependslist = candver.DependsList
- for dep in dependslist.keys():
- if dep == 'Depends' and dep == 'PreDepends' or dep == 'Recommends':
- for depVerList in dependslist[dep]:
- for z in depVerList:
- for tpkg in z.AllTargets():
- if depends_name == tpkg.ParentPkg.Name:
- return True
-
-
-
- depends_name == tpkg.ParentPkg.Name
-
- return False
-
-
- def clean(self):
- self._depcache.Init()
- if self._depcache.BrokenCount > 0:
- print [](_[1])
- self._depcache.Init()
-
- if self._depcache.DelCount > 0:
- print [](_[2])
- self._depcache.Init()
-
- if not self._depcache.DelCount == 0:
- raise AssertionError
-
-
- def getArch(self):
- ''' Return the cpu architecture of the system'''
- return self._arch
-
-
- def getDependantAutoDeps(self, to_rm):
- ''' return the installed automatic dependencies for the selected set
- of packages that are going to be removed '''
- auto_deps = set()
- for pkg in to_rm:
- self[pkg].markDelete()
-
- for pkg in self:
- if not (pkg.markedDelete) and self._depcache.IsGarbage(pkg._pkg):
- for rm_package in to_rm:
- if self.pkgDependsOn(rm_package, pkg.name):
- print '%s is garbage and a dep of %s' % (pkg.name, rm_package)
- auto_deps.add(pkg.name)
- continue
-
-
- return auto_deps
-
-
-